package com.wain.util;

import cn.hutool.core.io.FileUtil;
import cn.hutool.core.util.ReUtil;

import java.io.File;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;

public class Distinct {
    public static void main(String[] args) {
        File file =new File("C:\\Users\\ｐｃ\\Desktop\\TestDistinct\\Distinct.txt");
        File outFile =new File("C:\\Users\\ｐｃ\\Desktop\\TestDistinct\\Distinct_1.txt");
        String str = FileUtil.readUtf8String(file);
        String regex = "\\<util:constant[^/>]*/>";
        List<String> resultList = ReUtil.findAll(regex, str, 0, new ArrayList<>());
        Set<String> uniqueElements = new HashSet<>(resultList);
        String resultString = uniqueElements.stream().collect(Collectors.joining("\n"));
        FileUtil.writeUtf8String(resultString, outFile);
    }
}
